using System;

namespace PropertyExpression.ReactiveRelation
{
    public static class CalcStorageExtensions
    {
        public static ICalcExecutor CreateCalcExecutor<TCalcContext>(
            this Func<CalcStorage<TCalcContext>> calcStorageFunc,
            Func<TCalcContext> calcContextFunc)
        {
            return new CalcExecutor<TCalcContext>(calcStorageFunc, calcContextFunc);
        }

        public static Func<ICalcExecutor> CreateCalcExecutorFactory<TCalcContext>(
            Action<ICalcRegistrator<TCalcContext>> initAction)
        {
            var calcStorage = new CalcStorage<TCalcContext>(initAction);
            return () => CreateCalcExecutor(() => calcStorage, () => default(TCalcContext));
        }
    }
}